package pers.muci.es.index;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @ClassName IndexDelete
 * @Description TODO
 * @Author muci
 * @Date 2021/12/21 21:54
 * @Version 1.0
 **/
public class IndexDelete {
    public static void main(String[] args) throws IOException {
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(new HttpHost("106.14.15.56", 9200, "http"))
        );

        DeleteIndexRequest user = new DeleteIndexRequest("user");
        AcknowledgedResponse delete = client.indices().delete(user, RequestOptions.DEFAULT);
        //响应状态
        System.out.println("索引删除：  " + delete.isAcknowledged());

        client.close();
    }
}
